package com.dts;

import java.sql.*;

public class JdbcUtils {


    public static Connection getConnection() {
        try{
            Class.forName("com.mysql.cj.jdbc.Driver"); //Mysql数据库
            String url = "jdbc:mysql://localhost:3306/cdes?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
            Connection conn = DriverManager.getConnection(url, "root", "123456");
            return conn;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    public static void close(Connection conn) {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
